<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title><?php echo $title;?></title>
		<link rel="stylesheet" href="../public/css/style.css">
	</head>
	<body>
		<div class="top">
			<div class="top-title">在线考试系统 - 考试结束（耗时 <span class="timeout"><?php echo $strTime;?></span>）</div>
		</div>
		<div class="main">
			<div class="main-wrap">
				
				<table class="total-table">
					<tr>
						<th>题型</th>
						<th>题号</th>
						<th>考生答案</th>
						<th>正确答案</th>
						<th>答题情况</td>
						<th>得分</th>
					</tr>
					
					<?php foreach($j as $k=>$v):?>
					<tr>
						<!-- 题型 -->
						<td rowspan="<?php echo $_POST['judgeCount'];?>"><?php echo $k;?></td>
						<?php $i = 0;foreach($v as $k1 => $v1):$i++?>
						<!-- 题号 -->
						<td><?php echo $i;?></td>
						<!-- 考生答案 -->
						<td><?php echo $v1;?></td>
						
						<!-- 正确答案 -->
						<td><?php echo $trueAnswerJudgeCount[$i-1];?></td>
						
						<!-- 答题情况 -->
						<td>
							<?php if($v1 == $trueAnswerJudgeCount[$i-1]){
									echo "<span style='color:green;font-weight:bold;'>对</span>";
								}else{
									echo "<span style='color:red;font-weight:bold;'>错</span>";
								}
							?>
						</td>
						<!-- 得分 -->
						<td>
							<?php if($v1 == $trueAnswerJudgeCount[$i-1]){
									echo "1";
									$judgeScore = $judgeScore+1;
								}else{
									echo "0";
								}
							?>
						</td>
					</tr>
						<?php endforeach;?>
					<?php endforeach;?>
					
					<?php foreach($s as $k=>$v):?>
					<tr>
						<!-- 题型 -->
						<td rowspan="<?php echo $_POST['singleCount'];?>"><?php echo $k;?></td>
						<?php $i = 0;foreach($v as $k1 => $v1):$i++;?>
						<!-- 题号 -->
						<td><?php echo $i;?></td>
						<!-- 考生答案 -->
						<td><?php echo $v1;?></td>
						<!-- 正确答案 -->
						<td><?php echo $trueAnswerSingleCount[$i-1];?></td>
						<!-- 答题情况 -->
						<td><?php if($v1 == $trueAnswerSingleCount[$i-1]){
									echo "<span style='color:green;font-weight:bold;'>对</span>";
								}else{
									echo "<span style='color:red;font-weight:bold;'>错</span>";
								}
							?>
						</td>
						<!-- 得分 -->
						<td>
							<?php if($v1 == $trueAnswerSingleCount[$i-1]){
									echo "1";
									$singleScore = $singleScore+1;
								}else{
									echo "0";
								}
							?>
						</td>
					</tr>
						<?php endforeach;?>
					<?php endforeach;?>
					
					<?php foreach($m as $k=>$v):?>
					<tr>
						<!-- 题型 -->
						<td rowspan="<?php echo $_POST['multipleCount'];?>"><?php echo $k;?></td>
						<?php $i = 0;foreach($v as $k1 => $v1):$i++;?>
						<!-- 题号 -->
						<td><?php echo $i;?></td>
						<!-- 考生答案 -->
						<td>
						<?php $kd = array();
						if(is_array($v1)){
								foreach($v1 as $k2=>$v2){
									//echo $v2;
									//遍历出考生答案，付给一个数组，转化成字符串
									$kd[] = $v2;
								}
							$str = implode("",$kd);
							echo $str;
						}
						?>
						</td>
						<!-- 正确答案 -->
						<td>
							<?php echo $trueAnswerMultipleCount[$i-1];?>
						</td>
						<!-- 答题情况 -->
						<td>
							<?php if($str == $trueAnswerMultipleCount[$i-1]){
									echo "<span style='color:green;font-weight:bold;'>对</span>";
								}else{
									echo "<span style='color:red;font-weight:bold;'>错</span>";
								}
							?>
						</td>
						<!-- 得分 -->
						<td>
							<?php if($str == $trueAnswerMultipleCount[$i-1]){
									echo "1";
									$multipleScore = $multipleScore+1;
								}else{
									echo "0";
								}
							?>
						</td>
					</tr>
						<?php endforeach;?>
					<?php endforeach;?>
					
					<?php foreach($f as $k=>$v):?>
					<tr>
						<!-- 题型 -->
						<td rowspan="<?php echo $_POST['fillCount'];?>"><?php echo $k;?></td>
						<?php $i = 0;foreach($v as $k1 => $v1):$i++;?>
						<!-- 题号 -->
						<td><?php echo $i;?></td>
						<!-- 考生答案 -->
						<td><?php echo $v1;?></td>
						<!-- 正确答案 -->
						<td><?php echo $trueAnswerFillCount[$i-1];?></td>
						<!-- 答题情况 -->
						<td>
							<?php if($v1 == $trueAnswerFillCount[$i-1]){
									echo "<span style='color:green;font-weight:bold;'>对</span>";
								}else{
									echo "<span style='color:red;font-weight:bold;'>错</span>";
								}
							?>
						</td>
						<!-- 得分 -->
						<td>
							<?php if($v1 == $trueAnswerFillCount[$i-1]){
									echo "1";
									$fillScore = $fillScore+1;
								}else{
									echo "0";
								}
							?>
						</td>
					</tr>
						<?php endforeach;?>
					<?php endforeach;?>
				</table>
				<div class="main-title center">
					<?php echo $name;?>的成绩：<?php $sumScore = $judgeScore+$singleScore+$fillScore+$multipleScore; echo $sumScore;?>分
					<?php 
						$sql = "insert into score values(null,'$name','$sumScore','$strTime')";
						//echo $sql;
						$res = mysqli_query($link,$sql);
						if($res){
							echo "<span style='color:green;font-weight:bold;'>成绩记录成功</span>";
						}else{
							echo "<span style='color:red;font-weight:bold;'>成绩记录失败</span>";
							//echo mysqli_error($Link);
						}
					?>
				</div>
				
				<div class="total-act">
					<a href="../index.php">返回首页</a>
				</div>
			</div>
		</div>
		
		<div class="footer">
			PHP在线考试系统　本项目仅供学习使用
		</div>
	</body>
</html>